package com.none.web.controller.param;


import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;









import com.none.core.common.utils.JSONUtil;
import com.none.core.model.Result;
import com.none.web.common.SysConstant;
import com.none.web.service.param.IParamService;

/**
 * 参数管理Controller
 * 
 * @author Summer
 * 
 */
@Controller
@RequestMapping("param")
public class ParamController {

	@Resource(name = "paramService")
	IParamService paramService;

	@Autowired
	private HttpServletRequest request;
	/**
	 * 根据键查询参数
	 * 
	 * @param paramKey
	 * @return
	 * @throws Exception
	 */
	@ResponseBody
	@RequestMapping("getParamByKey")
	public Object getParamByKey(String paramKey) throws Exception {
		String[] filter = new String[] {};

		Map<String, Object> data = new HashMap<String, Object>();
		Result result = new Result(SysConstant.STATE_SUCCESS, "golbal.success", data);

		data.put("param", paramService.getParamByKey(paramKey));
		return JSONUtil.toJSON(result, filter);
	}
	/**
	 * 查询所有参数
	 * 
	 * @return
	 * @throws Exception
	 */
	@ResponseBody
	@RequestMapping("getAllParam")
	public Object getAllParam() throws Exception {
		String[] filter = new String[] {};

		Map<String, Object> data = new HashMap<String, Object>();
		Result result = new Result(SysConstant.STATE_SUCCESS, "golbal.success", data);

		data.put("param", paramService.getAllParam());
		return JSONUtil.toJSON(result, filter);
	}
}
